#!/usr/bin/python
# -*- coding: cp1250 -*-

import time
timenow = lambda : time.strftime ("%Y%m%dT%H%M%S", time.localtime())

class SW:
    ''' stop watches

    import pepe.p_datetime.stopwatches as stwa

    sw = stwa.SW()
    print sw.start()
    time.sleep(2)
    print sw.slice()
    time.sleep(2)
    print sw.slice()
    time.sleep(2)
    print sw.stop()
    '''
    def __init__(self):
        ''' '''
    def start(self):
        self.tstart = time.mktime(time.localtime())
        self.tslice = time.mktime(time.localtime())
        return timenow()

    def slice(self):
        self.tnow = time.mktime(time.localtime())
        self.tdiff = (int(self.tnow-self.tslice),
                      float((self.tnow-self.tslice)/60))
        self.tslice = time.mktime(time.localtime())
        return  " %14d sec (%0.2f min)" % self.tdiff
        
    def total(self):
        self.tnow = time.mktime(time.localtime())
        self.tdiff = (int(self.tnow-self.tstart),
                      float((self.tnow-self.tstart)/60))
        return  " %14d sec (%0.2f min)" % self.tdiff
        
    def stop(self):
        self.tstop = time.mktime(time.localtime())
        self.tdiff = (int(self.tstop-self.tstart),
                      float((self.tstop-self.tstart)/60))
        return timenow() + "\nTotal: %8d sec (%0.2f min)" % self.tdiff

if __name__ == '__main__':
    ''' '''
    sw = SW()
    print sw.start()
    time.sleep(2)
    print sw.slice()
    time.sleep(2)
    print sw.slice()
    time.sleep(2)
    print sw.stop()
